//
//  OrganizationViewController.m
//  Civacrm
//
//  Created by mubei on 17/2/15.
//  Copyright © 2017年 王桂敏. All rights reserved.
//

#import "OrganizationViewController.h"
#import "SchoolInfoTableViewCell.h"
#import "BottomView.h"
@interface OrganizationViewController ()

@property (nonatomic, strong) NSArray *dataSource;

@property (nonatomic, strong) NSArray *TitledataSource;

@end

@implementation OrganizationViewController

#pragma mark - life cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"机构详情";
    [self initData];
    [self initView];
}

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
}

-(void)initData {
    
    self.TitledataSource = @[@[@"机构商标",@"机构名称",@"校长姓名"], @[@"银行卡号",@"账户余额"], @[@"手机号码",@"电子邮箱",@"机构地址"]];

    self.dataSource = @[@[self.iconURL, self.orgName, self.legalPerson],@[self.cardNum, self.balance],@[self.phone, self.orgEmail, self.orgAdress]];
    
}

-(void)initView {
    
    self.view.backgroundColor = ColorWithHexString(@"f2f9fa");
    
    self.tableView.frame = CGRectMake(0, 0, self.view.width, self.view.height - 64 - h(80));
    self.tableView.backgroundColor = ClearColor;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.tableView registerClass:[SchoolInfoTableViewCell  class] forCellReuseIdentifier:@"SchoolInfoTableViewCell"];
    
    BottomView * bottomView = [BottomView initBottomViewWithFrame:CGRectMake(0, kScreenHeight - h(80) - 64, kScreenWidth, h(80)) andActivateNumString:self.activeString andPayForNumString:self.payforString];
    [self.view addSubview:bottomView];
    

}

#pragma mark - UITableViewDelegate

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 3;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if (section == 1) {
        return 2;
    }
    else {
        return 3;
    }
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    switch (indexPath.section) {
        case 0:
            if (indexPath.row == 0) {
                return h(138);
            }
            break;
        case 2:
            if (indexPath.row == 2) {
                return h(138);
            }
            break;
            
        default:
            break;
    }
    
    return h(100);
    
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    
    UIView *footView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, h(20))];
    footView.backgroundColor = ClearColor;
    
    return footView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    if (section == 2) {
        return CGFLOAT_MIN;
    }
    else {
        return h(20);
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    SchoolInfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SchoolInfoTableViewCell"];
    
    cell.titleLabel.text = self.TitledataSource[indexPath.section][indexPath.row];
    [cell configViewWithString:self.dataSource[indexPath.section][indexPath.row] indexPath:indexPath];
    
    return cell;
}

#pragma mark - get and setter


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
